/**
 * 动画样式文件
 * 定义项目中使用的CSS动画和过渡效果
 */

@import './variables.scss';

// ==================== 基础动画 ====================

/**
 * 淡入动画
 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/**
 * 淡出动画
 */
@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/**
 * 向上淡入动画
 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/**
 * 向下淡入动画
 */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/**
 * 向左淡入动画
 */
@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/**
 * 向右淡入动画
 */
@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/**
 * 缩放淡入动画
 */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/**
 * 缩放淡出动画
 */
@keyframes fadeOutScale {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.8);
  }
}

// ==================== 滑动动画 ====================

/**
 * 向上滑入动画
 */
@keyframes slideInUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/**
 * 向下滑入动画
 */
@keyframes slideInDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

/**
 * 向左滑入动画
 */
@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

/**
 * 向右滑入动画
 */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

/**
 * 向上滑出动画
 */
@keyframes slideOutUp {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-100%);
  }
}

/**
 * 向下滑出动画
 */
@keyframes slideOutDown {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(100%);
  }
}

/**
 * 向左滑出动画
 */
@keyframes slideOutLeft {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

/**
 * 向右滑出动画
 */
@keyframes slideOutRight {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100%);
  }
}

// ==================== 缩放动画 ====================

/**
 * 放大动画
 */
@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
  }
  to {
    transform: scale(1);
  }
}

/**
 * 缩小动画
 */
@keyframes zoomOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: scale(0.3);
  }
}

/**
 * 弹性放大动画
 */
@keyframes bounceIn {
  0%, 20%, 40%, 60%, 80% {
    animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
  }
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  20% {
    transform: scale(1.1);
  }
  40% {
    transform: scale(0.9);
  }
  60% {
    opacity: 1;
    transform: scale(1.03);
  }
  80% {
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/**
 * 弹性缩小动画
 */
@keyframes bounceOut {
  20% {
    transform: scale(0.9);
  }
  50%, 55% {
    opacity: 1;
    transform: scale(1.1);
  }
  to {
    opacity: 0;
    transform: scale(0.3);
  }
}

// ==================== 旋转动画 ====================

/**
 * 旋转动画
 */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/**
 * 反向旋转动画
 */
@keyframes rotateReverse {
  from {
    transform: rotate(360deg);
  }
  to {
    transform: rotate(0deg);
  }
}

/**
 * 摇摆动画
 */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-10px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(10px);
  }
}

/**
 * 摆动动画
 */
@keyframes swing {
  20% {
    transform: rotate(15deg);
  }
  40% {
    transform: rotate(-10deg);
  }
  60% {
    transform: rotate(5deg);
  }
  80% {
    transform: rotate(-5deg);
  }
  to {
    transform: rotate(0deg);
  }
}

// ==================== 脉冲动画 ====================

/**
 * 脉冲动画
 */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/**
 * 心跳动画
 */
@keyframes heartbeat {
  0% {
    transform: scale(1);
  }
  14% {
    transform: scale(1.3);
  }
  28% {
    transform: scale(1);
  }
  42% {
    transform: scale(1.3);
  }
  70% {
    transform: scale(1);
  }
}

/**
 * 呼吸动画
 */
@keyframes breathe {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

// ==================== 加载动画 ====================

/**
 * 旋转加载动画
 */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/**
 * 点点加载动画
 */
@keyframes dotLoading {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/**
 * 波浪加载动画
 */
@keyframes waveLoading {
  0%, 60%, 100% {
    transform: initial;
  }
  30% {
    transform: translateY(-15px);
  }
}

/**
 * 弹跳加载动画
 */
@keyframes bounceLoading {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

// ==================== 特效动画 ====================

/**
 * 闪烁动画
 */
@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0;
  }
}

/**
 * 打字机动画
 */
@keyframes typewriter {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

/**
 * 光标闪烁动画
 */
@keyframes cursor {
  0%, 50% {
    border-color: transparent;
  }
  51%, 100% {
    border-color: currentColor;
  }
}

/**
 * 渐变背景动画
 */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/**
 * 浮动动画
 */
@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-20px);
  }
}

/**
 * 弹跳动画
 */
@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
    transform: translateY(0);
  }
  40%, 43% {
    animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
    transform: translateY(-30px);
  }
  70% {
    animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
    transform: translateY(-15px);
  }
  90% {
    transform: translateY(-4px);
  }
}

// ==================== 动画工具类 ====================

// 淡入动画类
.fade-in {
  animation: fadeIn $animation-duration-base $animation-timing-function-enter;
}

.fade-out {
  animation: fadeOut $animation-duration-base $animation-timing-function-leave;
}

.fade-in-up {
  animation: fadeInUp $animation-duration-base $animation-timing-function-enter;
}

.fade-in-down {
  animation: fadeInDown $animation-duration-base $animation-timing-function-enter;
}

.fade-in-left {
  animation: fadeInLeft $animation-duration-base $animation-timing-function-enter;
}

.fade-in-right {
  animation: fadeInRight $animation-duration-base $animation-timing-function-enter;
}

.fade-in-scale {
  animation: fadeInScale $animation-duration-base $animation-timing-function-enter;
}

.fade-out-scale {
  animation: fadeOutScale $animation-duration-base $animation-timing-function-leave;
}

// 滑动动画类
.slide-in-up {
  animation: slideInUp $animation-duration-base $animation-timing-function-enter;
}

.slide-in-down {
  animation: slideInDown $animation-duration-base $animation-timing-function-enter;
}

.slide-in-left {
  animation: slideInLeft $animation-duration-base $animation-timing-function-enter;
}

.slide-in-right {
  animation: slideInRight $animation-duration-base $animation-timing-function-enter;
}

.slide-out-up {
  animation: slideOutUp $animation-duration-base $animation-timing-function-leave;
}

.slide-out-down {
  animation: slideOutDown $animation-duration-base $animation-timing-function-leave;
}

.slide-out-left {
  animation: slideOutLeft $animation-duration-base $animation-timing-function-leave;
}

.slide-out-right {
  animation: slideOutRight $animation-duration-base $animation-timing-function-leave;
}

// 缩放动画类
.zoom-in {
  animation: zoomIn $animation-duration-base $animation-timing-function-enter;
}

.zoom-out {
  animation: zoomOut $animation-duration-base $animation-timing-function-leave;
}

.bounce-in {
  animation: bounceIn $animation-duration-slow $animation-timing-function-enter;
}

.bounce-out {
  animation: bounceOut $animation-duration-slow $animation-timing-function-leave;
}

// 旋转动画类
.rotate {
  animation: rotate 2s linear infinite;
}

.rotate-reverse {
  animation: rotateReverse 2s linear infinite;
}

.shake {
  animation: shake 0.82s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.swing {
  animation: swing 1s ease-in-out;
}

// 脉冲动画类
.pulse {
  animation: pulse 2s infinite;
}

.heartbeat {
  animation: heartbeat 1.5s ease-in-out infinite;
}

.breathe {
  animation: breathe 3s ease-in-out infinite;
}

// 加载动画类
.spin {
  animation: spin 1s linear infinite;
}

.dot-loading {
  animation: dotLoading 1.4s infinite ease-in-out both;
}

.wave-loading {
  animation: waveLoading 1.2s infinite ease-in-out;
}

.bounce-loading {
  animation: bounceLoading 1.4s infinite ease-in-out both;
}

// 特效动画类
.blink {
  animation: blink 1s infinite;
}

.typewriter {
  animation: typewriter 3s steps(40, end);
}

.cursor {
  animation: cursor 1s infinite;
}

.gradient-shift {
  animation: gradientShift 3s ease infinite;
  background-size: 400% 400%;
}

.float {
  animation: float 3s ease-in-out infinite;
}

.bounce {
  animation: bounce 2s infinite;
}

// ==================== 动画延迟类 ====================

.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }
.delay-900 { animation-delay: 0.9s; }
.delay-1000 { animation-delay: 1s; }

// ==================== 动画时长类 ====================

.duration-fast { animation-duration: $animation-duration-fast; }
.duration-normal { animation-duration: $animation-duration-base; }
.duration-slow { animation-duration: $animation-duration-slow; }

// ==================== 动画填充模式类 ====================

.fill-none { animation-fill-mode: none; }
.fill-forwards { animation-fill-mode: forwards; }
.fill-backwards { animation-fill-mode: backwards; }
.fill-both { animation-fill-mode: both; }

// ==================== 动画播放状态类 ====================

.paused { animation-play-state: paused; }
.running { animation-play-state: running; }

// ==================== 动画重复次数类 ====================

.infinite { animation-iteration-count: infinite; }
.once { animation-iteration-count: 1; }
.twice { animation-iteration-count: 2; }
.thrice { animation-iteration-count: 3; }

// ==================== 过渡动画类 ====================

.transition-all {
  transition: all $animation-duration-base ease;
}

.transition-opacity {
  transition: opacity $animation-duration-base ease;
}

.transition-transform {
  transition: transform $animation-duration-base ease;
}

.transition-colors {
  transition: color $animation-duration-base ease,
              background-color $animation-duration-base ease,
              border-color $animation-duration-base ease;
}

.transition-shadow {
  transition: box-shadow $animation-duration-base ease;
}

// ==================== 悬停效果类 ====================

.hover-scale:hover {
  transform: scale(1.05);
}

.hover-scale-sm:hover {
  transform: scale(1.02);
}

.hover-scale-lg:hover {
  transform: scale(1.1);
}

.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba($primary-color, 0.4);
}

.hover-rotate:hover {
  transform: rotate(5deg);
}

.hover-brightness:hover {
  filter: brightness(1.1);
}

.hover-blur:hover {
  filter: blur(2px);
}

// ==================== 响应式动画 ====================

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

// 移动端优化
@media (max-width: 768px) {
  .fade-in-up,
  .fade-in-down,
  .fade-in-left,
  .fade-in-right {
    animation-duration: $animation-duration-fast;
  }
  
  .slide-in-up,
  .slide-in-down,
  .slide-in-left,
  .slide-in-right {
    animation-duration: $animation-duration-fast;
  }
}